<?php
/*
 *  A Part of snock project
 *   Author king-of-war
 * Last modified 2009-4-22
 *
 */
 @session_start();
 $root_path='../';
 include_once $root_path . 'admin/smarty_config.php';
include_once $root_path . 'admin/class/fun_common.php';
include_once $root_path . 'admin/class/guest.class.php';
include_once $root_path . 'admin/class/cfg.class.php';

/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(3);
/*
 * get page_num
 */
$cfg=new cfg($root_path);
  $page_size=$cfg->xml_read('page_num');


$fun = new fun_common($root_path);

$max = $fun->getAll('guest_book', 1);
/*
 * page moudle start
 *
 */
if (!empty ($_GET['p'])) {
	$page = $_GET['p'];
} else {
	$page = 1;
}
$pages = $fun->page($page, $page_size, $max);
/*
 * page moulde  end
 *
 *  sort_read($arr)
 */
$arr[0] = $pages['start'];
$arr[1] =  $page_size;
/*
 * get the comment of guests
 */
 $info='留言删除';

 $guest=new guest($root_path);



$guests=$guest->guest_read($arr,1);


/*
 * guest delete moudle
 */

if (isset($_POST['Submit'])) {


		$t=0;
	for ($i = 0; $i < $max; $i++) {

		$id = $guests[$i]['id'];

		if ($_POST[$id]!= '') {

			$ids[$t]=$id;
			$t++;
		}

	}
print_r($ids);


	 $line=$guest->guest_del($ids);

if($line){
	$info= '成功删除'.$line.'条留言';
}else{
	$info=  '删除失败';
};
}



/*
 *  set template
 *
 */
$smarty->assign("info",$info);
$smarty->assign("guest", $guests);
$smarty->assign("page", $pages);
$smarty->assign("url", $root_path);
$smarty->display("guest_del.html");

?>


